﻿namespace Kurax.BoardGames.Client.Engine.Commands {
    public sealed class RequestSessionKey : CommandBase {
        public override int CommandId {
            get {
                return 0; // 0, 0, 0, 0
            }
        }

        protected internal override byte[] GetBodyData() {
            return Credentials.ClientKey;
        }

        protected internal override void OnServerResponsed(byte[] data) {
            var crypto = new Crypto();
            var serverKey = crypto.Decrypt(data, Credentials.ClientKey);
            if(serverKey.Length == 0)
                return;
            Credentials.SetSessionKey(serverKey);
        }
    }
}
